package com.huyun.web.base;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class test3 {
    public static void main(String[] arr){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String b = sc.next();
        char[] s = str.toCharArray();
        int num = 0;
        Map<String,Integer> map = new HashMap<>();
        for(int i=0;i<s.length;i++){
            if(b.equalsIgnoreCase(String.valueOf(s[i]))){
                num++;
            }
            map.put(String.valueOf(s[i]).toUpperCase(),num);
        }

        System.out.println(map.get(b.toUpperCase()));
    }
}
